package com.ysx.wemedia.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ysx.wemedia.dto.WmNewsDto;
import com.ysx.wemedia.pojo.WmNews;
import com.ysx.wemedia.vo.WmNewsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 自媒体图文内容信息表 Mapper 接口
 * </p>
 *
 * @author ljh
 * @since 2021-09-08
 */
public interface WmNewsMapper extends BaseMapper<WmNews> {
    //查询待审核列表
    @Select("select wm.*,us.id as authorName  from wm_news wm,wm_user us where wm.user_id =us.id and wm.`status` BETWEEN 2 and 3 and title like concat('%',#{searchKeyWord},'%') limit #{page},#{size}")
    List<WmNewsVo> getSearchNotPass(@Param("page") Long page, @Param("size")Long size, @Param("searchKeyWord")WmNewsDto searchKeyWord);
    //查询待审核列表数量
    @Select("select count(*)  from wm_news wm,wm_user us where wm.user_id =us.id and wm.`status` BETWEEN 2 and 3 and title like concat('%',#{searchKeyWord},'%')")
    Long CountNotPassNum(@Param("searchKeyWord") WmNewsDto searchKeyWord);

    //根据文章id联表查询文章信息和作者用户
    @Select("select wm.*,us.id as authorName  from wm_news wm,wm_user us where #{wmNewsId} =us.id ")
    WmNewsVo findWmNewsStatus(@Param("wmNewsId") Integer wmNewsId);
}
